// <copyright file="DummyAutoCompleteHandler.cs" company="YUIAsp.Net">
// Copyright (c) 2009 All Right Reserved
// </copyright>
// <author>raul popescu</author>
// <email>dev@yuiasp.net</email>
// <date>2009-01-30</date>
// <summary>YUIAsp.Net File</summary>

using System.Threading;
using YUIAspNet;

namespace YUIAspNetDemo.AutoComplete
{
    /// <summary>
    /// Dummy handler used to send data to the AutoComplete control
    /// </summary>
    public class DummyAutoCompleteHandler : BaseAutoCompleteHandler
    {
        /// <summary>
        /// Gets the results to send to the AutoComplete control.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="maxItems">The max items.</param>
        /// <param name="autoCompleteCode">The auto complete code.</param>
        /// <returns>A LocalDataSource containing data to return to the client.</returns>
        public override LocalDataSource GetResults(string query, int maxItems, string autoCompleteCode)
        {
            // sleep for 3 seconds, to fake server processing
            Thread.Sleep(3000); 

            LocalDataSource src = new LocalDataSource();
            src.AddColumn("value");
            for (int i = 0; i < maxItems; i++)
                src.AddRow(query + i);

            return src;
        }
    }
}
